<template>
	<view class="container">
		
		<view class="content" style="display: flex;">
			<view style="width: 50%;">
				<button class="t1" @tap="goto" data-url="pages/money/moneylog?st=0" style="background-color: #a5c44d;border-radius: 15rpx;font-size: 30rpx;margin: 20rpx;">余额明细</button>
			</view>
			<view style="width: 50%;">
				<button class="t1" @tap="goto" data-url="poster" style="background-color: #a5c44d;border-radius: 15rpx;font-size: 30rpx;margin: 20rpx;">邀请他人</button>
			</view>
		</view>
		<view class="content" v-if="is_wx"  @tap="goto" data-url="/activity/yuyue/webviews">
			<view class="label">
				<view style="width: 70%;">
					<text class="t1">关注公众号</text>
				</view>
				<view style="text-align: right;width: 30%;">
					<text class="t1_2">去完成 ></text>
				</view>
			</view>
				<view class="item">
					<view class="f1">
						<image src="https://new.qdnxxt.cn/upload/22/20240224/0731fce98d5f220ecffb47de820159a5.png"></image>
						<view class="t2">
							<text class="x1">到家佳</text>
							<text class="x2">您的家庭服务平台</text>
						</view>
					</view>
					<view class="f2">
						<view class="x1">即送<text style="color: red;font-size: 40rpx;">8.88元</text></view>
					</view>
				</view>
		</view>
		
		
		
		<view class="content" @tap="lingqu">
			<view class="label" >
				<view style="width: 70%;">
					<text class="t1">已邀请：{{invite_count}}人，已完成：{{invite_over}}人</text>
				</view>
				<view style="text-align: right;width: 30%;">
					<text class="t1_2">去领取 ></text>
				</view>
			</view>
			<view class="label">
				<view>
					<view class="x1">每邀请1人下单完工送<text style="color: red;">5.0元</text></view>
					<view class="x1">邀请10人下单完工送<text style="color: red;">50.0元</text></view>
				</view>
			</view>
			
			<block v-for="(item, index) in datalist" :key="index">
				<view class="item">
					<view class="f1">
						<image :src="item.headimg"></image>
						<view class="t2">
							<text class="x1">{{item.name}}</text>
							<text class="x2">ID:{{item.child_mid}}</text>
							<text class="x2">{{dateFormat(item.createtime,'Y-m-d H:i')}}</text>
						</view>
					</view>
					<view class="f2">
						<view class="x1" style="color: red;font-size: 30rpx;"  v-if="item.status < 0">未下单</view>
						<view class="x1" style="color: #ffaa00;font-size: 30rpx;"  v-if="item.status == 0 || item.status == 1 || item.status == 2">下单中</view>
						<view class="x1" style="color: green;font-size: 30rpx;"  v-if="item.status == 3">已完成,审核中</view>
						<view class="x1" style="color: green;font-size: 30rpx;"  v-if="item.status == 4">已完成</view>
					</view>
				</view>
			</block>
		</view>

	</view>
</template>

<script>
	var app = getApp();

	export default {
		data() {
			return {
				opt: {},
				loading: false,
				datalist: [],
				pagenum: 1,
				userlevel: {},
				userinfo: {},
				textset: {},
				levelList: {},
				keyword: '',
				nodata: false,
				nomore: false,
				invite_count: 0,
				invite_over: 0,
				is_wx: 1
			};
		},

		onLoad: function(opt) {
			this.opt = app.getopts(opt);
			
		},
		onShow() {
			this.getdata();
		},
		onPullDownRefresh: function() {
			this.getdata();
		},
		methods: {
			getdata: function(loadmore) {
				var that = this;
				that.loading = true;
				app.post('ApiAgent/team_red', {}, function(res) {
					that.loading = false;
					that.datalist = res.data.datalist;
					that.invite_count = res.data.invite_count;
					that.invite_over = res.data.invite_over;
					// that.is_wx = !res.data.is_wx;
				});
			},
			lingqu(){
				app.post('ApiAgent/team_inspect', {}, function(res) {
					if(res.code == 1){
						uni.showModal({
						        title: '未满足条件',
						        content: '每邀请1人下单完工即打款5元！',
						        cancelText: "取消",
						        confirmText: "去邀请",
						        confirmColor:'blue',
						        cancelColor:'#000000',
						        success: function(res) {
						        if (res.confirm) {
						            app.goto('poster');
						        }
						    }
						})
					}else if(res.code == 2){
						uni.showModal({
						        title: '快去多多邀请吧！',
						        content: res.msg,
						        cancelText: "取消",
						        confirmText: "去邀请",
						        confirmColor:'blue',
						        cancelColor:'#000000',
						        success: function(res) {
						        if (res.confirm) {
						            app.goto('poster');
						        }
						    }
						})
					}
				});
				
				
			}
		}
	};
</script>
<style>

	.t1_2{
		color: #333;
		font-weight: bold;
		font-size: 30rpx;
		
	}
	
	.content {
		width: 94%;
		margin: 0 3%;
		border-radius: 16rpx;
		background: #fff;
		margin-top: 20rpx;
	}

	.content .label {
		display: flex;
		width: 100%;
		padding: 16rpx;
		color: #333;
	}
	
	.content .t1 {
		font-weight: bold;
		color: #333;
		font-size: 30rpx;
	}

	.content .item {
		width: 100%;
		padding: 32rpx;
		border-top: 1px #eaeaea solid;
		min-height: 112rpx;
		display: flex;
		align-items: center;
	}

	.content .item image {
		width: 90rpx;
		height: 90rpx;
		border-radius: 4px
	}

	.content .item .f1 {
		display: flex;
		flex: 1;
		align-items: center;
	}
	
	.content .item .f2 {
		/* width: 40%; */
	}

	.content .item .f1 .t2 {
		display: flex;
		flex-direction: column;
		padding-left: 20rpx;
	}

	.content .item .f1 .t2 .x1 {
		color: #333;
		font-size: 26rpx;
	}

	.content .item .f1 .t2 .x2 {
		color: #999;
		font-size: 24rpx;
	}
</style>